package com.jhh.pay.center.service.impl;

import com.jhh.pay.center.service.ExistChecker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import redis.clients.jedis.JedisCluster;

/**
 * @author tangxd
 * @Description: TODO
 * @date 2018/1/16
 */
@Component
public class RedisExistChecker implements ExistChecker {

    @Autowired
    private JedisCluster cluster;

    @Override
    public boolean exist(String key, String field) {
        return cluster.sismember(key, field);
    }

    @Override
    public void add(String key, String field) {
        cluster.sadd(key, field);
    }

    @Override
    public void rmv(String key, String field) {
        cluster.srem(key, field);
    }
}
